package com.huakang.service.impl;

import com.huakang.entity.Docter;
import com.huakang.entity.DocterExample;
import com.huakang.mapper.DocterMapper;
import com.huakang.service.DocterService;
import com.huakang.utils.DocterVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * @Author{小熊}
 * @Date2025/1/10 22:52
 */
@Service
@Transactional
public class DocterServiceImpl implements DocterService {
    @Autowired
    private DocterMapper docterMapper;


    @Override
    public List<DocterVo> getAll() {
        return docterMapper.getAll();
    }

    @Override
    public boolean delete(Integer did) {
        return docterMapper.deleteByPrimaryKey(did)>0;
    }

    @Override
    public boolean add(Docter docter) {
        return docterMapper.insert(docter)>0;
    }

    @Override
    public Docter getById(Integer did) {
        return docterMapper.selectByPrimaryKey(did);
    }

    @Override
    public boolean updateDoctor(Docter docter) {
        return docterMapper.updateByPrimaryKeySelective(docter)>0;
    }

    @Override
    public List<DocterVo> getByCondition(String dname, String dename, String kname) {
        return docterMapper.getByCondition(dname,dename,kname);
    }

    @Override
    public List<Docter> kidAll(Integer kid) {
        DocterExample docterExample = new DocterExample();
        DocterExample.Criteria criteria = docterExample.createCriteria();
        criteria.andKidEqualTo(kid);
        List<Docter> docters = docterMapper.selectByExample(docterExample);
        return docters;
    }


    @Override
    public List<Docter> getKid(Integer kid) {
        DocterExample example=new DocterExample();
        DocterExample.Criteria criteria = example.createCriteria();
        criteria.andKidEqualTo(kid);
        return docterMapper.selectByExample(example);
    }
}
